package cn.ciis.basic.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

/**
 * 设置 pjax 标志
 *
 * @author 冉志林
 */
public class PjaxInterceptor implements Interceptor {

  @Override
  public void intercept(Invocation inv) {
    try {
      inv.invoke();
    } finally {
      Controller c = inv.getController();
      boolean isPjax = "true".equalsIgnoreCase(c.getHeader("X-PJAX"));
      c.setAttr("isPjax", isPjax);
    }
  }
}
